using UnityEngine;
using System.Collections;

public abstract class GameModeBaseScript {
	public enum ModeState
	{
		State_None,
		State_Idle,
		State_Fire,
		State_Update,
		State_End,
		State_Num,
	}
	
	public class FireEvent : System.EventArgs
	{
		public Ray inPutRay;
	}
	
	public void Init()
	{
		InitStateMechanic();
	}
	
	public bool SwithState( ModeState changeToState, System.EventArgs e )
	{
		if ( stateMechanics[ (int)curState ].CanChangeTo( (int)changeToState ) )
		{
			stateMechanics[ (int)curState ].breakFunction( this, e );
			stateMechanics[ (int)changeToState ].stateFunction( this, e );
			return true;
		}
		return false;
	}
	
	public bool Operate( Ray inPutRay, bool fire ) 
	{
		if ( curState != ModeState.State_Idle )
			return false;
		GameModeBaseScript.FireEvent fireEvent = new GameModeBaseScript.FireEvent();
		fireEvent.inPutRay = inPutRay;
		if ( fire )
		{
			SwithState( ModeState.State_Fire, fireEvent as System.EventArgs );
			//SwitchToFire ( this , fireEvent );
		}
		else
		{
			screenMsg.SetFocus( inPutRay );
		}
		return true;
	}
	
	public abstract void SetDifficult(int difficult );

	public abstract void InitStateMechanic();
	public abstract void InitScreen();
	public abstract void Update();
	
	
	public StateMechanicScript[]	stateMechanics = new StateMechanicScript[(int)ModeState.State_Num];
	public GameMsgScript	gameMsg;
	public ScreenMsgScript	screenMsg;
	
	public float		gameTime = 30.0f;
	public float		curTime ;
	
	public ModeState	curState = ModeState.State_None;
	
	public int				Vertical = 10;
	public int				Horizontal = 10;
	public int				score = 0;
	
}
